<?php
class ReminderForm extends AppModel {
	var $useTable = false;
	var $name = 'ReminderForm';

	var $validate = array(
		'email' => array(
			'email' => array(
				'rule' => 'email',
				'required' => true,
				'message' => Messages::invalid_email_address
			),
			'isUnique' => array(
				'rule' => 'isExistEmail',
				'message' => Messages::email_has_not_been_existed
			)
		)
	);

	/**
	 * Check if email is registered or not
	 * @param $email
	 * @return bool
	 */
	function isExistEmail($email){
		App::import('model','User');
		$user = new User();
		$result = $user->findByEmail($email);
		if($result){
			return true;
		}else{
			return false;
		}
	}

}